C++ Arrays and Pointers: Why Is the Array Name a Pointer?

In C++, an array is a contiguous block of memory used to store multiple elements of the same type (e.g., `int a[5]` stores 5 integers). A pointer is a "roadmap" that points to a memory address, recording the location of a variable or element. A key property of an array name: the array name represents the address of the first element. For example, after defining `int a[5] = {5, 15, 25, 35, 45}`, the system allocates contiguous memory. Assuming the address of `a[0]` is `0x7ffeefbff500` (where an `int` typically occupies 4 bytes), the address of `a[1]` is `0x7ffeefbff504` (differing by 4 bytes). This pattern continues, with each element's address increasing consecutively. Core conclusion: The value of the array name `a` is equal to the address of the first element `&a[0]`, i.e., `a ≡ &a[0]`.

Read More